﻿using System;
using UnityEngine;
using UnityEngine.UI;

public class SnackMakerUI : MonoBehaviour
{

    public Button MakeSnackA;
    public Button MakeSnackB;
    public Button MakeSnackC;
    
    private SnackFactoryMgr snackFactoryMgr;
    
    private void Awake()
    {
        snackFactoryMgr = SnackFactoryMgr.GetInstance();
        
        MakeSnackA.onClick.AddListener(OnClickMakeSnackA);
        MakeSnackB.onClick.AddListener(OnClickMakeSnackB);
        MakeSnackC.onClick.AddListener(OnClickMakeSnackC);
    }

    private void OnClickMakeSnackA()
    {
        Snack snack = snackFactoryMgr.GetFactory(eProductType.SnackAFactory).GetProduct();
        Debug.Log("零食名字：" + snack.SnackName);
        Debug.Log("零食描述：" +  snack.SnackDesc);
    }
    
    private void OnClickMakeSnackB()
    {
        Snack snack = snackFactoryMgr.GetFactory(eProductType.SnackBFactory).GetProduct();
        Debug.Log("零食名字：" + snack.SnackName);
        Debug.Log("零食描述：" +  snack.SnackDesc);
    }
    private void OnClickMakeSnackC()
    {
        Snack snack = snackFactoryMgr.GetFactory(eProductType.SnackCFactory).GetProduct();
        Debug.Log("零食名字：" + snack.SnackName);
        Debug.Log("零食描述：" +  snack.SnackDesc);
    }
    
    private void OnDestroy()
    {
        MakeSnackA.onClick.RemoveAllListeners();
        MakeSnackB.onClick.RemoveAllListeners();
        MakeSnackC.onClick.RemoveAllListeners();
    }
}